﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DadayunApi.Model
{
    public class AppAuthBase
    {
        /// <summary>
        /// 申请应用时分配的AppKey。
        /// </summary>
        public string AppKey { get; set; }
        /// <summary>
        /// 申请应用时分配的AppSecret。
        /// </summary>
        public string AppSecret { get; set; }
        /// <summary>
        /// 授权类型，此处的值固定为password。 默认值: password
        /// </summary>
        public string GrantType { get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
        /// <summary>
        /// 申请scope权限所需参数，可一次申请多个scope权限，用空格分隔。
        /// </summary>
        public string Scope { get; set; }
        public string TenantName { get; set; }
        public string PublicKey { get; set; }
        public string ClientId { get { return AppKey; } }
        public string ClientSecret { get { return AppSecret; } }

        public bool IsUsefull()
        {
            bool empty = string.IsNullOrEmpty(AppKey) || string.IsNullOrEmpty(AppSecret)
                || string.IsNullOrEmpty(TenantName) || string.IsNullOrEmpty(Username)
                || string.IsNullOrEmpty(Password);
            return !empty;
        }
    }
}
